#include "link_list.h"
Element_data Stu_data[50]=
{
 { .name = "刘备" , .sex = "男" , .sco = 60 , .age = 18 , .id = 1  },
 { .name = "关羽" , .sex = "男" , .sco = 60 , .age = 18 , .id = 2  },
 { .name = "张飞" , .sex = "女" , .sco = 60 , .age = 18 , .id = 3  },
 { .name = "诸葛" , .sex = "男" , .sco = 60 , .age = 18 , .id = 4  },
 { .name = "赵云" , .sex = "男" , .sco = 60 , .age = 18 , .id = 5  },
 { .name = "马超" , .sex = "男" , .sco = 60 , .age = 18 , .id = 6  },
 { .name = "祝融" , .sex = "女" , .sco = 60 , .age = 18 , .id = 7  },
 { .name = "小乔" , .sex = "女" , .sco = 60 , .age = 18 , .id = 8  },
 { .name = "大乔" , .sex = "女" , .sco = 60 , .age = 18 , .id = 9  },
 { .name = "貂蝉" , .sex = "女" , .sco = 60 , .age = 18 , .id = 10  }  
};
void test(void)
{
    Link_list *L=init_link_list();

//遍历
Node * ptr = L->next;
    for (size_t i = 0; ptr != NULL; i++)
    {
        printf("姓名:%s 性别:%s 年龄:%d 成绩:%d 学号:%d\n",
            ptr->data.name , ptr->data.sex , ptr->data.age , 
            ptr->data.sco  , ptr->data.id 
            );
        ptr = ptr->next;
    }

    free_link_list(&L);
}
void tests(void) {
    Link_list *L = init_link_list();

    if (L == NULL) {
        printf("链表初始化失败\n");
        return;
    }

    for (int i = 0; i < 5; ++i) {
        append_node(L, Stu_data[i]);
    }

    Node *ptr = L->next;
    while (ptr != NULL) {
        printf("姓名:%s 性别:%s 年龄:%d 成绩:%d 学号:%d\n",
            ptr->data.name, ptr->data.sex, ptr->data.age,
            ptr->data.sco, ptr->data.id);
        ptr = ptr->next;
    }

    remove_last_node(L);

    printf("\n删除最后一个节点:\n");

    ptr = L->next;
    while (ptr != NULL) {
        printf("姓名:%s 性别:%s 年龄:%d 成绩:%d 学号:%d\n",
            ptr->data.name, ptr->data.sex, ptr->data.age,
            ptr->data.sco, ptr->data.id);
        ptr = ptr->next;
    }

    free_link_list(&L);
}
int main()
{
    test();
    tests();
    return 0;
}